package com.cn.crmsystem.controller.approveController;

import com.cn.crmsystem.pojo.*;
import com.cn.crmsystem.service.approveService.ReturnService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Controller
@Api(value = "审核回款api",tags = "审核回款API")
public class ReturnController {
	@Autowired ReturnService returnService;
	//查询
	@RequestMapping(value = "/SelectReturned",name = "查询审核回款",method = RequestMethod.POST)
	@ApiOperation(value = "查询审核回款",notes = "全查",httpMethod = "POST", response = String.class)
	@ResponseBody
	public ResultJson selectReturn(){
		ResultJson resultJson=new ResultJson();
		Login login=new Login();
		login.setUser_id(15);
		login.setUserName("菜鸡");
		Integer userid=login.getUser_id();
		Map<String,Object>  map=new HashMap<>();
		map.put("checkperson",login);
		map.put("checkdata",returnService.ReturnSelect(userid));
		System.out.println(userid);
		resultJson.getSuccess("data",map);
		return resultJson;
	}
	//修改
	@RequestMapping(value = "/UpdateReturned",name = "修改审核回款",method = RequestMethod.POST)
	@ApiOperation(value = "修改审核回款",notes = "更改deleteid",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "appid",value = "审核id",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "state",value = "状态",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public  ResultJson ReturnUpdate(@RequestParam(name = "appid") Integer appid,
									@RequestParam(name = "state") Integer state){
		ResultJson resultJson=new ResultJson();
		resultJson=returnService.UpdateReturn(appid,state);
		return  resultJson;
	}
	//删除
	@RequestMapping(value = "/DeleteReturned",name = "删除审核回款",method = RequestMethod.POST)
	@ApiOperation(value = "删除审核回款",notes = "更改deleteid",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "appid",value = "审核id",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public  ResultJson DeleteReturn(@RequestParam(name = "appid") Integer appid){
		ResultJson resultJson=new ResultJson();
		resultJson=returnService.DeleteReturn(appid);
		return  resultJson;
	}
	//条件查询
	@RequestMapping(value = "/SelectCondtionReturn",name = "审核回款条件查询",method = RequestMethod.POST)
	@ApiOperation(value = "审核状态切换",notes = "条件查询",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "state",value = "审核状态",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public ResultJson SelectCondtionReturn(
											 @RequestParam(name = "state") Integer state ){

		ResultJson resultJson=new ResultJson();
		Login login=new Login();
		login.setUser_id(15);
		login.setUserName("菜鸡");
		Integer userid=login.getUser_id();
		Map<String,Object>  map=new HashMap<>();
		map.put("checkperson",login);
		map.put("checkdata",returnService.SelectConditionRturn(userid,state));
		System.out.println(userid);
		resultJson.getSuccess("data",map);
		return resultJson;
	}
}
